-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PoC: Resolution CLI #246
PoC: Resolution CLI #246
Conversation
7382e7d
to
bdb76b4
Compare
93e0010
to
2ec7e6c
Compare
0e10978
to
1c3a3ad
Compare
c425615
to
1c0b2db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good to me with the idea in mind that this still has a good bit of follow up work to do to get it production ready. I had a minor nit but nothing that should block this PR IMO.
I'm not very well versed in the variable source / deppy stuff so I'd definitely prefer someone more familiar with that review it prior to merging in case I've missed something.
Great work @m1kola !
func validateFlags(packageName, indexRef string) error { | ||
if packageName == "" { | ||
return fmt.Errorf("missing required -%s flag", flagNamePackageName) | ||
} | ||
|
||
if indexRef == "" { | ||
return fmt.Errorf("missing required -%s flag", flagNameIndexRef) | ||
} | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: If these flags are required would it make more sense to make them positional arguments? IMO flags should be reserved for configurable options.
I noticed we aren't using spf13/cobra
for building the CLI commands, but it has some nice support for setting required number of arguments that we could use here and automatically generates a pretty nice help message that could be used to show the required positional arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a fan of explicit arguments; it can get confusing with positional unless there's an explicit logic (e.g. kubectl
's verb type [name])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package name probably makes sense as a positional argument and everything else as flags. But I suggest that we leave it as is for now and come back to discuss details of the interface once start work on finalising this CLI.
We are not using cobra right now, but I think we should use it in the production-ready version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small changes (mostly copyright years). However, I would like to see this incorporated in the Makefile
as either a target that's automatically built, or a separate target.
} | ||
|
||
// build variable source pipeline | ||
variableSource := crdconstraints.NewCRDUniquenessConstraintsVariableSource(bundlesanddependencies.NewBundlesAndDepsVariableSource(inputVariableSources...)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to add CRD Uniqueness and Bundle variable sources to the list, but I don't see them in the new code?
Unless it's wrapped by NewOLMVariableSource
, but I don't see it being used.
I guess it's the NewOLMVariableSource()
"constructor" that's adding these, rather than the GetVariables
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to remove this chaining within the variable source becase for off-cluster usage we need a bit different set of variable soruces (e.g. we need a variable source which creates a variable from CLI inputs).
instead of chaining I now use NestedVariableSource
in NewOLMVariableSource
(note after #273 it is NewOperatorVariableSource
). NewOLMVariableSource
is used in on-cluster operator and it is not in this diff (I did not change the calling code).
But NewCRDUniquenessConstraintsVariableSource
and NewBundlesAndDepsVariableSource
are also used in off-cluster resolution here within olm.NestedVariableSource
.
I suspect NestedVariableSource
and probably whole composite.go
will go away once we switch to the solution proposed in the RFC.
func init() { | ||
utilruntime.Must(clientgoscheme.AddToScheme(scheme)) | ||
utilruntime.Must(operatorsv1alpha1.AddToScheme(scheme)) | ||
utilruntime.Must(rukpakv1alpha1.AddToScheme(scheme)) | ||
utilruntime.Must(catalogd.AddToScheme(scheme)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the init()
function necessary, give that this is a CLI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do it in main
I think, but I was following the pattern from operator-controller's main.go
:
operator-controller/cmd/manager/main.go
Lines 49 to 57 in ebc5cfe
func init() { | |
utilruntime.Must(clientgoscheme.AddToScheme(scheme)) | |
utilruntime.Must(operatorsv1alpha1.AddToScheme(scheme)) | |
utilruntime.Must(rukpakv1alpha1.AddToScheme(scheme)) | |
utilruntime.Must(catalogd.AddToScheme(scheme)) | |
//+kubebuilder:scaffold:scheme | |
} |
func validateFlags(packageName, indexRef string) error { | ||
if packageName == "" { | ||
return fmt.Errorf("missing required -%s flag", flagNamePackageName) | ||
} | ||
|
||
if indexRef == "" { | ||
return fmt.Errorf("missing required -%s flag", flagNameIndexRef) | ||
} | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a fan of explicit arguments; it can get confusing with positional unless there's an explicit logic (e.g. kubectl
's verb type [name])
8fb5a8a
to
7e3c73a
Compare
Codecov Report
@@ Coverage Diff @@
## main #246 +/- ##
==========================================
+ Coverage 76.13% 77.00% +0.86%
==========================================
Files 13 15 +2
Lines 662 687 +25
==========================================
+ Hits 504 529 +25
Misses 129 129
Partials 29 29
|
a28b436
to
90db305
Compare
Signed-off-by: Mikalai Radchuk <[email protected]>
Signed-off-by: Mikalai Radchuk <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tmshort I think I addressed your feedback + made sure this PR doesn't decrease test coverage.
However, I would like to see this incorporated in the Makefile as either a target that's automatically built, or a separate target.
I did not want to add this into makefile or goreleaser because it is still a PoC and a lot will change. Didn't want to make it "official" for now.
But if you think that we should still do that - I suggest that we do it in a separate PR.
"github.com/operator-framework/operator-controller/internal/resolution/variablesources" | ||
) | ||
|
||
func NewVariableSource(cl client.Client) variablesources.NestedVariableSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved it here from internal/resolution/variablesources/
. The idea is that building blocks are in internal/resolution/variablesources/
and this composite variable source is close to where it will be used (in controller or in the off-cluster.
@@ -109,86 +87,11 @@ var _ = Describe("OLMVariableSource", func() { | |||
}))) | |||
}) | |||
|
|||
It("should produce BundleVariables variables", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These removed tests are mostly to cover inner variables sources which are no longer hardcoded inside (see this) and have their own tests (bundles_and_dependencies_test.go
, required_package_test.go
, etc).
I would like to see a m |
Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](docker/login-action@v2...v3) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Description
This is a PoC for #206.
Right now the tool is capable of resolving a package without a cluster: it is possible to provide a FBC (dir or an image) into the tool as well as a directory containing manifests with
Operator
objects.The resolution tool will use
Operator
from the input manifests and consider them required (as if they were installed on a cluster).Once we merge this, the next steps will be:
Also there are a few things going in parallel. For example, we will likely change significantly how we build resolution problems (see operator-framework/deppy#96 and relevant RFC). Once we have more or less stable way to build the resolution problem - we will be able to create some sort of library to share between operator-controller and resolution CLI.
Example usage:
Reviewer Checklist